<!-- 项目详情列表 子页面  报价单-->
<template>
  <a-card :bordered="false" class="card-area">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <!-- 搜索区域 -->
      <a-form layout="inline" >
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="单据编号" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <a-input placeholder="请输入单据编号查询" v-model="queryParam.billNo"></a-input>
            </a-form-item>
          </a-col>
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
            <a-col :md="6" :sm="24">
              <a-button type="primary" @click="searchQuery(1)">查询</a-button>
              <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
            </a-col>
          </span>
        </a-row>
      </a-form>
    </div>
    <!-- 操作按钮区域 -->
    <div class="table-operator"  style="margin-top:5px">
      <a-button v-if="btnEnableList.indexOf(1)>-1" @click="myHandleAdd" type="primary" icon="plus">新增</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" v-if="btnEnableList.indexOf(1)>-1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作 <a-icon type="down" />
        </a-button>
      </a-dropdown>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource1"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="myHandleDetail(record, '报价单')">查看</a>
          <a-divider v-if="btnEnableList.indexOf(1)>-1" type="vertical" />
          <a v-if="btnEnableList.indexOf(1)>-1" @click="myHandleEdit(record,)">编辑</a>
          <a-divider v-if="btnEnableList.indexOf(1)>-1" type="vertical" />
          <a-popconfirm v-if="btnEnableList.indexOf(1)>-1" title="确定删除吗?" @confirm="() => onDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <details-list-modal ref="modalForm" @ok="modalFormOk" :id=id ></details-list-modal>
    <bill-detail3 ref="modalDetail" :id=ids  :depot=depot   v-if="visible1"  :visible="visible1" :billType="'报价单'"  :engineeringId="id" @guan="guan" ></bill-detail3>
  </a-card>
</template>
<script>
  import detailsListModal from './detailsListModal'
  import BillDetail from '../../bill/dialog/BillDetail'
  import BillDetail3 from '../detail/BillDetail3'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { BillListMixin } from '../../bill/mixins/BillListMixin'
  import { findDetailList,deleteEngineeringDepot } from '@/api/api'
  import JDate from '@/components/jeecg/JDate'
  import Vue from 'vue'
  export default {
    name: "projectDetailsList",
    mixins:[JeecgListMixin,BillListMixin],
    components: {
      detailsListModal,
      BillDetail,BillDetail3,
      JDate
    },
    inject:["reload"],
    props: ['id'],
    data () {
      return {
        visible1:false,
        dataSource1:[],
        ids:'',
        depot:'',
        currentPage:1,
        pageSize:10 ,
        // 查询条件
        queryParam: {
          billNo:'',
          materialName:'',
          number: "",
          searchMaterial: "",
          type: "出库",
          subType: "销售",
          roleType: Vue.ls.get('roleType')
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        // 表头
        columns: [
         
          { title: '报价单ID', dataIndex: 'id',width:100,align:"center",},
          { title: '客户名称', dataIndex: 'supplierName',width:100},
          { title: '单据编号', dataIndex: 'billNo',width:140,},
          { title: '商品名称', dataIndex: 'materialName',width:120, ellipsis:true,},
          { title: '单据日期', dataIndex: 'billTime',width:145},
          { title: '操作员', dataIndex: 'createUserName',width:80},
          { title: '金额合计', dataIndex: 'commodityPrice',width:80},
          {title: '价税合计', dataIndex: 'taxCommodityDecimalTotal', width: 80,},
          {
            title: '操作',
            dataIndex: 'action',
            align:"center", width: 150,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          //  列表数据
          // list: "/depotHead/list",
          list:"/engineering/findEngineeringDepot",
          // 删除
          delete: "/depotHead/delete",

          deleteBatch: "/depotHead/deleteBatch"
        }
      }
    },
    computed: {
       
    },
    mounted () {
    },
    created () {
      this.detailList()
    },
    methods: {
      myHandleDetail(record){
        this.visible1 = true

        //  this.$emit('showOrderDetail',record);
        console.log('showOrderDetail',656)
        this.$nextTick(() => {
          this.$refs.modalDetail.show(record,'报价单');
        });

        //this.$refs.modalDetail.show(record,'销售出库');
        console.log(record,6666)
      },
      guan() {
        this.visible1 = false
        this.close();
      },
    searchReset() {
      this.queryParam = {
        type: this.queryParam.type,
        subType: this.queryParam.subType
      }
      this.searchQuery(1);
    },
        detailList() {
            findDetailList({ 
                currentPage:1,
                pageSize:10,
                engineeringId:this.id,
              }).then((res) => {
              if ( res.code === 0) {
                this.dataSource1 = res.data.row
                this.ipagination.total = res.data.total
                this.ids = this.id
                this.depot = res.data.row.map(item => {
                    return {
                      id: item.id,
                    }
                })
                this.dataSource1 = res.data.row
                this.ipagination.total = res.data.total

                this.ipagination.current = 1;
                // this.depot = this.dataSource1.filter(item => item.id == id)[0]?this.dataSource1.filter(item => item.id == id)[0].id: ''
              console.log( this.depot ,8999)
              }
                // console.log(res.data.total,11)
                // console.log(this.dataSource1,999)
                // console.log(this.ipagination.total,999)
          })
        },
        searchQuery(page=1,pageSize=10){
            findDetailList({
                currentPage:page,
                pageSize:pageSize,
                billNo:this.queryParam.billNo,
                materialName:this.queryParam.materialName,
                engineeringId:this.id,
                }).then((res) => {
                if ( res.code === 0) {
                  this.dataSource1 = res.data.row
                  this.ipagination.total = res.data.total
                }
            })
        },
      // 分页事件
      handleTableChange(e){
        console.log('searchQuery', 9999999999999999)
        this.ipagination.current = e.current
        this.searchQuery(e.current)

      },
        onDelete(record){
            deleteEngineeringDepot({
              id:record
            }).then((res) =>{
              if( res.code === 0){
               this.$message.success('删除成功')
               this.reload()   
              }else{
                this.$message.warning(res.message);
              }
            })
        }
    }
  }
</script>
<style scoped>
</style>